package com.krtech.wecard.module.sys.pojo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.krtech.wecard.module.sys.entity.SysUser;
import com.krtech.wecard.module.sys.entity.SysUserRole;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class UserDto {
    @ApiModelProperty(value = "关键字")
    private String keyword;

    @ApiModelProperty(value = "身份标识")
    private String identityIds;

    @ApiModelProperty(value = "账号状态。1-激活，2-未激活")
    private String enable;

    @ApiModelProperty(value = "部门,0-本部门，1-下级部门，都有，就是都有")
    private String deptList;

    @ApiModelProperty(value = "部门Id")
    private Integer deptId;

    private List<String> identityIdList;

    private List<String> deptCodeList;

    private List<String> enableList;

    public void setEnable(String enable) {
        this.enable = enable;

        if (StrUtil.isNotEmpty(enable)){
            List<String> enableLists = Arrays.stream(enable.split(",")).collect(Collectors.toList());
            this.enableList = enableLists;
        }
    }

    public void setIdentityIds(String identityIds) {
        this.identityIds = identityIds;

        if (StrUtil.isNotEmpty(identityIds)){
            List<String> IdentityIdList = Arrays.stream(identityIds.split(",")).collect(Collectors.toList());
            this.identityIdList = IdentityIdList;
        }
    }

    //    public SysUser QueryWrapper<SysUser> queryWrapper() {
//        QueryWrapper<com.krtech.wecard.module.sys.entity.SysUser> queryWrapper = new QueryWrapper<>();
//
//        queryWrapper.in(StringUtils.isNotEmpty("enable"), "enable", enable);
//        queryWrapper.in(StringUtils.isNotEmpty("identity"), "identity", identity);
//        queryWrapper.and(StringUtils.isNotEmpty(keyword),
//                        likeQueryWrapper -> likeQueryWrapper.like("user_name", keyword)
//                                                .or().like("nick_name", keyword));
//        return queryWrapper;
//    }
}